package io.mft.redis.client;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import io.mft.redis.connection.RedisConfigure;
import io.mft.redis.connection.RedisConnManager;
import io.mft.redis.util.SerializeHelper;
import lombok.extern.slf4j.Slf4j;
import redis.clients.jedis.BinaryClient;
import redis.clients.jedis.BinaryClient.LIST_POSITION;
import redis.clients.jedis.BinaryJedisCommands;
import redis.clients.jedis.BitOP;
import redis.clients.jedis.BitPosParams;
import redis.clients.jedis.GeoCoordinate;
import redis.clients.jedis.GeoRadiusResponse;
import redis.clients.jedis.GeoUnit;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisCommands;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPubSub;
import redis.clients.jedis.MultiKeyCommands;
import redis.clients.jedis.Pipeline;
import redis.clients.jedis.PipelineBase;
import redis.clients.jedis.ScanParams;
import redis.clients.jedis.ScanResult;
import redis.clients.jedis.ShardedJedis;
import redis.clients.jedis.ShardedJedisPipeline;
import redis.clients.jedis.SortingParams;
import redis.clients.jedis.Tuple;
import redis.clients.jedis.ZParams;
import redis.clients.jedis.exceptions.JedisDataException;
import redis.clients.jedis.exceptions.JedisException;
import redis.clients.jedis.params.geo.GeoRadiusParam;
import redis.clients.jedis.params.sortedset.ZAddParams;
import redis.clients.jedis.params.sortedset.ZIncrByParams;

/**
 * 
 * 描述: redis的连接客户端
 * 版权: Copyright (c) 2008 
 * 公司: 思迪科技 
 * 作者: 刘宝
 * 版本: 1.0 
 * 创建日期: 2015-5-25 
 * 创建时间: 上午10:44:00
 */
@Slf4j
public class JedisClient
{
	
	
	private String id = "";
	
	public JedisClient()
	{
		id=RedisConfigure.getDefault();
	}
	
	public JedisClient(String id)
	{
		this.id = id;
	}
	
	/**
	 * 
	 * 描述：获取redis连接
	 * 作者：刘宝
	 * 时间：2015-5-25 下午07:40:40
	 * @return
	 */
	public Object getJedis()
	{
		Object jedis = null;
		for (int i = 0; i < 3; i++)
		{
			try
			{
				if (ObjectUtil.isNotEmpty(this.id))
				{
					jedis = RedisConnManager.getConnection(this.id);
				}
				else
				{
					jedis = RedisConnManager.getConnection();
				}
				if (jedis != null)
				{
					break;
				}
			}
			catch (JedisException e)
			{
				if (i == 2)
				{
					throw e;
				}
			}
			try
			{
				Thread.sleep(1000);
			}
			catch (InterruptedException e)
			{
				log.error("", e);
			}
		}
		if(jedis == null)
		{
			throw new JedisException("Could not get a resource from the pool");
		}
		return jedis;
	}
	
	/**
	 * 
	 * 描述：获取类型
	 * 作者：刘宝
	 * 时间：2017-4-28 下午09:57:11
	 * @param arg0
	 * @return
	 */
	public String type(String arg0)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				String result = jedis.type(arg0);
				if (ObjectUtil.isEmpty(result) || "nil".equalsIgnoreCase(result))
				{
					result = "";
				}
				return result;
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return "";
	}
	
	/**
	 * 
	 * 描述：缓存数据
	 * 作者：刘宝
	 * 时间：2015-5-25 下午07:58:08
	 * @param key
	 * @param value
	 */
	public boolean set(String key, String value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				String result = jedis.set(key, value);
				return "OK".equalsIgnoreCase(result);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return false;
	}
	
	/**
	 * 
	 * 描述：缓存数据
	 * 作者：刘宝
	 * 时间：2017-4-28 下午09:51:54
	 * @param arg0
	 * @param arg1
	 * @param arg2
	 * @param arg3
	 * @param arg4
	 * @return
	 */
	public boolean set(String arg0, String arg1, String arg2, String arg3, long arg4)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				String result = jedis.set(arg0, arg1, arg2, arg3, arg4);
				return "OK".equalsIgnoreCase(result);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return false;
	}
	
	/**
	 * 
	 * 描述：缓存数据
	 * 作者：刘宝
	 * 时间：2017-4-28 下午09:53:52
	 * @param arg0
	 * @param arg1
	 * @param arg2
	 * @return
	 */
	public boolean set(String arg0, String arg1, String arg2)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				String result = jedis.set(arg0, arg1, arg2);
				return "OK".equalsIgnoreCase(result);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return false;
	}
	
	/**
	 * 
	 * 描述：缓存数据
	 * 作者：刘宝
	 * 时间：2015-5-25 下午07:58:08
	 * @param key
	 * @param value
	 */
	public boolean set(String key, byte[] value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					String result = ((Jedis) jedis).set(key.getBytes(), value);
					return "OK".equalsIgnoreCase(result);
				}
				else if (jedis instanceof ShardedJedis)
				{
					String result = ((ShardedJedis) jedis).set(key.getBytes(), value);
					return "OK".equalsIgnoreCase(result);
				}
				else if (jedis instanceof JedisCluster)
				{
					String result = ((JedisCluster) jedis).set(key.getBytes(), value);
					return "OK".equalsIgnoreCase(result);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return false;
	}
	
	
	/**
	 * 
	 * 描述：缓存数据
	 * 作者：刘宝
	 * 时间：2015-5-25 下午08:56:43
	 * @param key
	 * @param values
	 * @return
	 */
	public boolean set(String key, List<Map<String, String>> value)
	{
		String jsonStr = JSONUtil.toJsonStr(value);
		return set(key, jsonStr);
	}
	
	/**
	 * 
	 * 描述：缓存数据，obj必须是支持序列化的对象
	 * 作者：刘宝
	 * 时间：2015-9-8 下午09:35:18
	 * @param key
	 * @param obj
	 * @return
	 */
	public boolean set(String key, Object obj)
	{
		return set(key, SerializeHelper.serialize(obj));
	}
	
	/**
	 * 
	 * 描述：设置缓存数据，并设定缓存的时间
	 * 作者：刘宝
	 * 时间：2015-5-25 下午08:12:34
	 * @param key
	 * @param value
	 * @param seconds
	 */
	public boolean set(String key, String value, int seconds)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				String result = jedis.setex(key, seconds, value);
				return "OK".equalsIgnoreCase(result);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return false;
	}
	
	/**
	 * 
	 * 描述：设置缓存数据，并设定缓存的时间
	 * 作者：刘宝
	 * 时间：2015-5-25 下午08:12:34
	 * @param key
	 * @param value
	 * @param seconds
	 */
	public boolean setex(String key, String value, int seconds)
	{
		return this.set(key, value, seconds);
	}
	
	/**
	 * 
	 * 描述：设置缓存数据，并设定缓存的时间
	 * 作者：刘宝
	 * 时间：2015-5-25 下午08:12:34
	 * @param key
	 * @param value
	 * @param seconds
	 */
	public boolean setex(String key, byte[] value, int seconds)
	{
		return this.set(key, value, seconds);
	}
	
	/**
	 * 
	 * 描述：设置缓存数据，并设定缓存的时间
	 * 作者：刘宝
	 * 时间：2015-5-25 下午08:12:34
	 * @param key
	 * @param value
	 * @param seconds
	 */
	public boolean set(String key, byte[] value, int seconds)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					String result = ((Jedis) jedis).setex(key.getBytes(), seconds, value);
					return "OK".equalsIgnoreCase(result);
				}
				else if (jedis instanceof ShardedJedis)
				{
					String result = ((ShardedJedis) jedis).setex(key.getBytes(), seconds, value);
					return "OK".equalsIgnoreCase(result);
				}
				else if (jedis instanceof JedisCluster)
				{
					String result = ((JedisCluster) jedis).setex(key.getBytes(), seconds, value);
					return "OK".equalsIgnoreCase(result);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return false;
	}
	
	public Long setrange(String paramString1, long paramLong, String paramString2)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.setrange(paramString1, paramLong, paramString2);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	public String getrange(String paramString, long paramLong1, long paramLong2)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				String result = jedis.getrange(paramString, paramLong1, paramLong2);
				if (ObjectUtil.isEmpty(result) || "nil".equalsIgnoreCase(result))
				{
					result = "";
				}
				return result;
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return "";
	}
	
	/**
	 * 
	 * 描述：获取key并设置key
	 * 作者：刘宝
	 * 时间：2017-4-28 下午10:36:44
	 * @param paramString1
	 * @param paramString2
	 * @return
	 */
	public String getSet(String paramString1, String paramString2)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				String result = jedis.getSet(paramString1, paramString2);
				if (ObjectUtil.isEmpty(result) || "nil".equalsIgnoreCase(result))
				{
					result = "";
				}
				return result;
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return "";
	}
	
	public Long setnx(String paramString1, String paramString2)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.setnx(paramString1, paramString2);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：批量获取数据
	 * 作者：刘宝
	 * 时间：2017-4-29 上午12:44:43
	 * @param keys
	 * @return
	 */
	public List<String> mget(String... keys)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).mget(keys);
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).mget(keys);
				}
				else
				{
					List<String> result = new ArrayList<String>();
					if (keys != null && keys.length > 0)
					{
						for (int i = 0; i < keys.length; i++)
						{
							String value = ((JedisCommands) jedis).get(keys[i]);
							if (ObjectUtil.isEmpty(value) || "nil".equalsIgnoreCase(value))
							{
								value = "";
							}
							result.add(value);
						}
					}
					return result;
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	public boolean mset(String... keys)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				String result = "";
				if (jedis instanceof Jedis)
				{
					result = ((Jedis) jedis).mset(keys);
				}
				else if (jedis instanceof ShardedJedis)
				{
					log.error("当前API[mset]不支持ShardedJedis分片模式。");
				}
				else if (jedis instanceof JedisCluster)
				{
					result = ((JedisCluster) jedis).mset(keys);
				}
				return "OK".equalsIgnoreCase(result);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return false;
	}
	
	public Long msetnx(String... keys)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).msetnx(keys);
				}
				else if (jedis instanceof ShardedJedis)
				{
					log.error("当前API[msetnx]不支持ShardedJedis分片模式。");
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).msetnx(keys);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	public Long renamenx(String key1, String key2)
	{
		
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).renamenx(key1, key2);
				}
				else if (jedis instanceof ShardedJedis)
				{
					log.error("当前API[renamenx]不支持ShardedJedis分片模式。");
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).renamenx(key1, key2);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：获取指定key的字符串的长度
	 * 作者：刘宝
	 * 时间：2017-4-28 下午11:09:17
	 * @param key
	 * @return
	 */
	public Long strlen(String key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.strlen(key);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：设置数据并设置失效时间，单位毫秒
	 * 作者：刘宝
	 * 时间：2017-4-28 下午10:40:51
	 * @param paramString1
	 * @param paramLong
	 * @param paramString2
	 * @return
	 */
	public boolean psetex(String key, long millSeconds, String value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				String result = jedis.psetex(key, millSeconds, value);
				return "OK".equalsIgnoreCase(result);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return false;
	}
	public boolean set(String key, Map<String, String> value)
	{
		String jsonStr = JSONUtil.toJsonStr(value);
		return set(key, jsonStr);
	}
	/**
	 * 
	 * 描述：设置缓存数据，并设定缓存的时间
	 * 作者：刘宝
	 * 时间：2015-5-25 下午09:00:54
	 * @param key
	 * @param value
	 * @param seconds
	 * @return
	 */
	public boolean set(String key, Map<String, String> value, int seconds)
	{
		String jsonStr = JSONUtil.toJsonStr(value);
		return set(key, jsonStr, seconds);
	}
	
	/**
	 * 
	 * 描述：设置缓存数据，并设定缓存的时间
	 * 作者：刘宝
	 * 时间：2015-5-25 下午09:00:54
	 * @param key
	 * @param value
	 * @param seconds
	 * @return
	 */
	public boolean set(String key, List<Map<String, String>> value, int seconds)
	{
		String jsonStr = JSONUtil.toJsonStr(value);
		return set(key, jsonStr, seconds);
	}
	
	/**
	 * 
	 * 描述：缓存数据，并设定缓存的时间，obj必须是支持序列化的对象
	 * 作者：刘宝
	 * 时间：2015-9-8 下午09:35:18
	 * @param key
	 * @param obj
	 * @return
	 */
	public boolean set(String key, Object obj, int seconds)
	{
		return set(key, SerializeHelper.serialize(obj), seconds);
	}
	
	/**
	 * 
	 * 描述：缓存数据，并设定缓存的时间，obj必须是支持序列化的对象
	 * 作者：刘宝
	 * 时间：2015-9-8 下午09:35:18
	 * @param key
	 * @param obj
	 * @return
	 */
	public boolean setex(String key, Object obj, int seconds)
	{
		return set(key, obj, seconds);
	}
	
	/**
	 * 
	 * 描述：获取缓存值
	 * 作者：刘宝
	 * 时间：2015-5-25 下午08:00:36
	 * @param key
	 * @return
	 */
	public String getString(String key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				String result = jedis.get(key);
				if (ObjectUtil.isEmpty(result) || "nil".equalsIgnoreCase(result))
				{
					result = "";
				}
				return result;
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return "";
	}
	
	/**
	 * 
	 * 描述：截取字符串
	 * 作者：刘宝
	 * 时间：2017-4-28 下午10:57:58
	 * @param key
	 * @param start
	 * @param end
	 * @return
	 */
	public String substr(String key, int start, int end)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				String result = jedis.substr(key, start, end);
				if (ObjectUtil.isEmpty(result) || "nil".equalsIgnoreCase(result))
				{
					result = "";
				}
				return result;
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return "";
	}
	
	/**
	 * 
	 * 描述：获取缓存值
	 * 作者：刘宝
	 * 时间：2015-5-25 下午08:00:36
	 * @param key
	 * @return
	 */
	public byte[] getBytes(String key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).get(key.getBytes());
				}
				else if (jedis instanceof ShardedJedis)
				{
					return ((ShardedJedis) jedis).get(key.getBytes());
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).get(key.getBytes());
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：获取缓存的值
	 * 作者：刘宝
	 * 时间：2015-5-25 下午09:02:27
	 * @param key
	 * @return
	 */
	public Map<String, String> getMap(String key)
	{
		String value = getString(key);
		if (ObjectUtil.isNotEmpty(value))
		{
			JSONObject o = JSONUtil.parseObj(value);
			Map<String, String>  map=new HashMap<>();
			o.entrySet().forEach(entry->{
				map.put(entry.getKey(), String.valueOf(entry.getValue()));
			});
			return map;
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：获取缓存的值
	 * 作者：刘宝
	 * 时间：2015-5-25 下午09:02:27
	 * @param key
	 * @return
	 */
	public List<Map<String, String>> getList(String key)
	{
		String value = getString(key);
		List<Map<String, String>> list=new ArrayList<>();
		if (ObjectUtil.isNotEmpty(value))
		{
			JSONArray jsonArray = JSONUtil.parseArray(value);
			for (Object object : jsonArray) {
				 JSONObject jsonObject=(JSONObject)object;
					Map<String, String>  map=new HashMap<>();
					jsonObject.entrySet().forEach(entry->{
						map.put(entry.getKey(), String.valueOf(entry.getValue()));
					});
					list.add(map);
			}
		}
		return list;
	}
	
	/**
	 * 
	 * 描述：获取缓存的序列化的对象
	 * 作者：刘宝
	 * 时间：2015-9-8 下午09:56:48
	 * @param key
	 * @return
	 */
	public Object getObject(String key)
	{
		byte[] value = getBytes(key);
		if (value != null && value.length > 0)
		{
			return SerializeHelper.unserialize(value);
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：设置数据的失效时间
	 * 作者：刘宝
	 * 时间：2015-5-25 下午09:33:04
	 * @param key
	 * @param seconds
	 */
	public Long expire(String key, int seconds)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.expire(key, seconds);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：设置数据的失效时间，单位毫秒
	 * 作者：刘宝
	 * 时间：2017-4-28 下午09:58:39
	 * @param arg0
	 * @param arg1
	 * @return
	 */
	public Long pexpire(String key, long millSeconds)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.pexpire(key, millSeconds);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：设置数据的失效时间
	 * 作者：刘宝
	 * 时间：2015-5-25 下午09:33:50
	 * @param key
	 * @param date
	 */
	public Long expireAt(String key, Date date)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.expireAt(key, (long)(date.getTime()/1000));
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：获取剩余的失效时间
	 * 作者：刘宝
	 * 时间：2015-5-25 下午09:37:58
	 * @param key
	 * @return
	 */
	public Long ttl(String key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.ttl(key);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：获取剩余的失效时间
	 * 作者：刘宝
	 * 时间：2017-4-28 下午10:02:44
	 * @param key
	 * @return
	 */
	public Long pttl(String key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.pttl(key);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：强制数据失效
	 * 作者：刘宝
	 * 时间：2015-5-25 下午09:39:42
	 * @param key
	 */
	public Long persist(String key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.persist(key);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：重命名key
	 * 作者：刘宝
	 * 时间：2015-5-25 下午10:42:04
	 * @param key
	 * @param key1
	 * @return
	 */
	public boolean rename(String key, String key1)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				String result = "";
				if (jedis instanceof Jedis)
				{
					result = ((Jedis) jedis).rename(key, key1);
				}
				else if (jedis instanceof JedisCluster)
				{
					result = ((JedisCluster) jedis).rename(key, key1);
				}
				else if (jedis instanceof BinaryJedisCommands)
				{
					byte[] value = ((BinaryJedisCommands) jedis).get(key.getBytes());
					if (value != null && value.length > 0)
					{
						result = ((BinaryJedisCommands) jedis).set(key1.getBytes(), value);
						if ("OK".equalsIgnoreCase(result))
						{
							((BinaryJedisCommands) jedis).del(key.getBytes());
						}
					}
				}
				else
				{
					String value = ((JedisCommands) jedis).get(key);
					if (ObjectUtil.isEmpty(value) || "nil".equalsIgnoreCase(value))
					{
						value = "";
					}
					if (ObjectUtil.isNotEmpty(value))
					{
						result = ((JedisCommands) jedis).set(key1, value);
						if ("OK".equalsIgnoreCase(result))
						{
							((JedisCommands) jedis).del(key);
						}
					}
				}
				return "OK".equalsIgnoreCase(result);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return false;
	}
	
	/**
	 * 
	 * 描述：是否包含指定的key
	 * 作者：刘宝
	 * 时间：2015-5-25 下午08:05:26
	 * @param key
	 * @return
	 */
	public boolean exists(String key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				Boolean result = jedis.exists(key);
				if (result != null)
				{
					return result.booleanValue();
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return false;
	}
	
	/**
	 * 
	 * 描述：是否存在
	 * 作者：刘宝
	 * 时间：2017-4-29 上午12:27:04
	 * @param key
	 * @return
	 */
	public Long exists(String... key)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).exists(key);
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).exists(key);
				}
				else
				{
					Long result = Long.valueOf(0);
					for (int index = 0; index < key.length; index++)
					{
						Boolean r = ((JedisCommands) jedis).exists(key[index]);
						if (r != null && r.booleanValue())
						{
							result += 1;
						}
					}
					return result;
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：删除key
	 * 作者：刘宝
	 * 时间：2015-5-25 下午08:06:39
	 * @param key
	 */
	public Long delete(String key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.del(key);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：删除多个key
	 * 作者：刘宝
	 * 时间：2017-4-29 上午12:20:53
	 * @param key
	 * @return
	 */
	public Long delete(String... key)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).del(key);
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).del(key);
				}
				else
				{
					Long result = Long.valueOf(0);
					for (int index = 0; index < key.length; index++)
					{
						result += ((JedisCommands) jedis).del(key[index]);
					}
					return result;
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：增长一个整形的值，返回增长后的值
	 * 作者：刘宝
	 * 时间：2015-5-25 下午08:25:33
	 * @param key
	 * @param integer
	 */
	public Long incrby(String key, long integer)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.incrBy(key, integer);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：增长一个浮点形的值，返回增长后的值
	 * 作者：刘宝
	 * 时间：2017-4-28 下午10:56:34
	 * @param key
	 * @param paramDouble
	 * @return
	 */
	public Double incrByFloat(String key, double paramDouble)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.incrByFloat(key, paramDouble);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Double.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：减小一个整形的值,返回减小后的值
	 * 作者：刘宝
	 * 时间：2015-5-25 下午08:26:42
	 * @param key
	 * @param integer
	 */
	public Long decrby(String key, long integer)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.decrBy(key, integer);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：自增长方法每次加1
	 * 作者：刘宝
	 * 时间：2016-6-16 下午07:59:51
	 * @param key
	 * @return
	 */
	public Long incr(String key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.incr(key);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：自减少方法每次减1
	 * 作者：刘宝
	 * 时间：2016-6-16 下午07:59:51
	 * @param key
	 * @return
	 */
	public Long decr(String key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.decr(key);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：扩展缓存的字符串
	 * 作者：刘宝
	 * 时间：2015-5-25 下午08:35:38
	 * @param key
	 * @param value
	 */
	public Long append(String key, String value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.append(key, value);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：查找key
	 * 作者：刘宝
	 * 时间：2016-6-16 下午08:12:26
	 * @param pattern
	 * @return
	 */
	public Set<String> keys(String pattern)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).keys(pattern);
				}
				else if (jedis instanceof JedisCluster)
				{
					Set<String> keys = new HashSet<String>();
					Map<String, JedisPool> clusterNodes = ((JedisCluster) jedis).getClusterNodes();
					for (String k : clusterNodes.keySet())
					{
						JedisPool jp = clusterNodes.get(k);
						Jedis connection = jp.getResource();
						try
						{
							keys.addAll(connection.keys(pattern));
						}
						finally
						{
							connection.close();
						}
					}
					return keys;
				}
				else if (jedis instanceof ShardedJedis)
				{
					Set<String> keys = new HashSet<String>();
					Collection<Jedis> nodes = ((ShardedJedis) jedis).getAllShards();
					for (Iterator iterator = nodes.iterator(); iterator.hasNext();)
					{
						Jedis connection = (Jedis) iterator.next();
						try
						{
							keys.addAll(connection.keys(pattern));
						}
						finally
						{
							connection.close();
						}
					}
					return keys;
				}
				else
				{
					Set<String> keys = new HashSet<String>();
					List<Jedis> jedisList = RedisConnManager.getSingleConns(this.id);
					if (jedisList != null && jedisList.size() > 0)
					{
						for (Iterator<Jedis> iterator = jedisList.iterator(); iterator.hasNext();)
						{
							Jedis jedis2 = (Jedis) iterator.next();
							try
							{
								Set<String> k = jedis2.keys(pattern);
								if (k != null && k.size() > 0)
								{
									keys.addAll(k);
								}
							}
							finally
							{
								jedis2.disconnect();
							}
						}
					}
					return keys;
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	public String echo(String paramString)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				String result = jedis.echo(paramString);
				if (ObjectUtil.isEmpty(result) || "nil".equalsIgnoreCase(result))
				{
					result = "";
				}
				return result;
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return "";
	}
	
	/**
	 * 
	 * 描述：移动数据
	 * 作者：刘宝
	 * 时间：2017-4-28 下午11:54:11
	 * @param key
	 * @param index
	 * @return
	 */
	public Long move(String key, int index)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.move(key, index);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：redis内置的设置Map对象方法
	 * 作者：刘宝
	 * 时间：2015-5-25 下午08:40:44
	 * @param key
	 * @param values
	 */
	public boolean hmset(String key, Map<String, String> value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				String result = jedis.hmset(key, value);
				return "OK".equalsIgnoreCase(result);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return false;
	}
	
	/**
	 * 
	 * 描述：redis内置的获取Map对象方法
	 * 作者：刘宝
	 * 时间：2015-5-25 下午08:45:14
	 * @param key
	 * @return
	 */
	public Map<String, String> hgetAll(String key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.hgetAll(key);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：redis内置的删除Map对象的方法
	 * 作者：刘宝
	 * 时间：2015-5-25 下午09:21:18
	 * @param key
	 */
	public Long hdelete(String key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				Set<String> keys = jedis.hkeys(key);
				if (keys != null && keys.size() > 0)
				{
					String[] args = new String[keys.size()];
					return jedis.hdel(key, keys.toArray(args));
				}
			}
		}
		catch (JedisDataException e)
		{
			return this.delete(key);
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：redis内置的设置Map对象指定key的指定field的方法
	 * 作者：刘宝
	 * 时间：2015-5-25 下午09:43:06
	 * @param key
	 * @param filed
	 * @param value
	 * @return
	 */
	public Long hset(String key, String field, String value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.hset(key, field, value);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：redis内置的获取Map对象指定key的指定filed的方法
	 * 作者：刘宝
	 * 时间：2017-4-13 下午07:45:19
	 * @param key
	 * @param field
	 * @return
	 */
	public String hget(String key, String field)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				String result = jedis.hget(key, field);
				if (ObjectUtil.isEmpty(result) || "nil".equalsIgnoreCase(result))
				{
					result = "";
				}
				return result;
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return "";
	}
	
	/**
	 * 
	 * 描述：redis内置的Map对象删除数据指定key的指定filed的数据
	 * 作者：刘宝
	 * 时间：2015-5-25 下午09:44:44
	 * @param key
	 * @param filed
	 */
	public Long hdelete(String key, String... field)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.hdel(key, field);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：redis内置的Map对象，判断指定key的指定filed字段是否存在
	 * 作者：刘宝
	 * 时间：2015-5-25 下午09:45:55
	 * @param key
	 * @param filed
	 */
	public boolean hexists(String key, String field)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				Boolean result = jedis.hexists(key, field);
				if (result != null)
				{
					return result.booleanValue();
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return false;
	}
	
	/**
	 * 
	 * 描述：redis内置的Map对象，获取指定key的所有filed字段
	 * 作者：刘宝
	 * 时间：2017-4-17 下午12:10:40
	 * @param key
	 * @return
	 */
	public Set<String> hkeys(String key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.hkeys(key);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：redis内置的Map对象，获取指定key的所有value值
	 * 作者：刘宝
	 * 时间：2017-4-17 下午12:10:40
	 * @param key
	 * @return
	 */
	public List<String> hvals(String key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.hvals(key);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：自增长方法
	 * 作者：刘宝
	 * 时间：2016-6-16 下午07:59:51
	 * @param key
	 * @return
	 */
	public Long hincrby(String key, String field, long value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.hincrBy(key, field, value);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	public Long hsetnx(String paramString1, String paramString2, String paramString3)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.hsetnx(paramString1, paramString2, paramString3);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：自增长方法
	 * 作者：刘宝
	 * 时间：2017-4-28 下午10:53:39
	 * @param paramString1
	 * @param paramString2
	 * @param paramDouble
	 * @return
	 */
	public Double hincrByFloat(String paramString1, String paramString2, double paramDouble)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.hincrByFloat(paramString1, paramString2, paramDouble);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Double.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述:表示返回hash长度
	 * 作者：刘宝
	 * 时间：2016-6-16 下午07:59:51
	 * @param key
	 * @return
	 */
	public Long hlen(String key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.hlen(key);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：批量获取集合的值
	 * 作者：刘宝
	 * 时间：2016-6-16 下午08:10:54
	 * @param key
	 * @param fields
	 * @return
	 */
	public List<String> hmget(String key, String... fields)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.hmget(key, fields);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：加入数据到队列头部
	 * 作者：刘宝
	 * 时间：2015-5-25 下午09:48:49
	 * @param key
	 * @param value
	 * @return
	 */
	public Long lpush(String key, String... value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.lpush(key, value);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：加入数据到队列头部
	 * 作者：刘宝
	 * 时间：2015-5-25 下午09:48:49
	 * @param key
	 * @param value
	 * @return
	 */
	public Long lpush(String key, byte[]... value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).lpush(key.getBytes(), value);
				}
				else if (jedis instanceof ShardedJedis)
				{
					return ((ShardedJedis) jedis).lpush(key.getBytes(), value);
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).lpush(key.getBytes(), value);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：加入数据到队列尾部
	 * 作者：刘宝
	 * 时间：2015-5-25 下午09:52:04
	 * @param key
	 * @param value
	 * @return
	 */
	public Long rpush(String key, String... value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.rpush(key, value);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：加入数据到队列尾部
	 * 作者：刘宝
	 * 时间：2015-5-25 下午09:52:04
	 * @param key
	 * @param value
	 * @return
	 */
	public Long rpush(String key, byte[]... value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).rpush(key.getBytes(), value);
				}
				else if (jedis instanceof ShardedJedis)
				{
					return ((ShardedJedis) jedis).rpush(key.getBytes(), value);
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).rpush(key.getBytes(), value);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：在指定元素之前插入数据
	 * 作者：刘宝
	 * 时间：2015-5-25 下午09:57:02
	 * @param key
	 * @param pivot
	 * @param value
	 * @return
	 */
	public Long linsert(String key, String pivot, String value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.linsert(key, LIST_POSITION.BEFORE, pivot, value);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：在指定元素之前插入数据
	 * 作者：刘宝
	 * 时间：2015-5-25 下午09:57:02
	 * @param key
	 * @param pivot
	 * @param value
	 * @return
	 */
	public Long linsert(String key, byte[] pivot, byte[] value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).linsert(key.getBytes(), LIST_POSITION.BEFORE, pivot, value);
				}
				else if (jedis instanceof ShardedJedis)
				{
					return ((ShardedJedis) jedis).linsert(key.getBytes(), LIST_POSITION.BEFORE, pivot, value);
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).linsert(key.getBytes(), LIST_POSITION.BEFORE, pivot, value);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：对一个列表进行修剪,让列表只保留指定区间内的元素，不在指定区间之内的元素都将被删除。
	 * 作者：刘宝
	 * 时间：2017-4-28 下午11:11:05
	 * @param key
	 * @param paramLong1
	 * @param paramLong2
	 * @return
	 */
	public boolean ltrim(String key, long paramLong1, long paramLong2)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				String result = jedis.ltrim(key, paramLong1, paramLong2);
				return "OK".equalsIgnoreCase(result);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return false;
	}
	
	/**
	 * 
	 * 描述：设置队列中的数据
	 * 作者：刘宝
	 * 时间：2015-5-25 下午09:59:27
	 * @param key
	 * @param index
	 * @param value
	 * @return
	 */
	public boolean lset(String key, long index, String value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				String result = jedis.lset(key, index, value);
				return "OK".equalsIgnoreCase(result);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return false;
	}
	
	/**
	 * 
	 * 描述：设置队列中的数据
	 * 作者：刘宝
	 * 时间：2015-5-25 下午09:59:27
	 * @param key
	 * @param index
	 * @param value
	 * @return
	 */
	public boolean lset(String key, long index, byte[] value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					String result = ((Jedis) jedis).lset(key.getBytes(), index, value);
					return "OK".equalsIgnoreCase(result);
				}
				else if (jedis instanceof ShardedJedis)
				{
					String result = ((ShardedJedis) jedis).lset(key.getBytes(), index, value);
					return "OK".equalsIgnoreCase(result);
				}
				else if (jedis instanceof JedisCluster)
				{
					String result = ((JedisCluster) jedis).lset(key.getBytes(), index, value);
					return "OK".equalsIgnoreCase(result);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return false;
	}
	
	/**
	 * 
	 * 描述：删除队列中的指定元素
	 * 作者：刘宝
	 * 时间：2015-5-25 下午10:02:45
	 * @param key
	 * @param value
	 * @param count
	 */
	public Long lrem(String key, String value, long count)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.lrem(key, count, value);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：删除队列中的指定元素
	 * 作者：刘宝
	 * 时间：2015-5-25 下午10:02:45
	 * @param key
	 * @param value
	 * @param count
	 */
	public Long lrem(String key, byte[] value, long count)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).lrem(key.getBytes(), count, value);
				}
				else if (jedis instanceof ShardedJedis)
				{
					return ((ShardedJedis) jedis).lrem(key.getBytes(), count, value);
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).lrem(key.getBytes(), count, value);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：获取子队列
	 * 作者：刘宝
	 * 时间：2015-5-25 下午10:06:45
	 * @param key
	 * @param start
	 * @param end
	 * @return
	 */
	public List<String> lrange(String key, long start, long end)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.lrange(key, start, end);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：获取子队列
	 * 作者：刘宝
	 * 时间：2015-5-25 下午10:06:45
	 * @param key
	 * @param start
	 * @param end
	 * @return
	 */
	public List<byte[]> lrange(byte[] key, long start, long end)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).lrange(key, start, end);
				}
				else if (jedis instanceof ShardedJedis)
				{
					return ((ShardedJedis) jedis).lrange(key, start, end);
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).lrange(key, start, end);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：从list 的头部删除元素，并返回删除元素
	 * 作者：刘宝
	 * 时间：2015-5-25 下午10:08:09
	 * @param key
	 */
	public String lpop(String key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				String result = jedis.lpop(key);
				if (ObjectUtil.isEmpty(result) || "nil".equalsIgnoreCase(result))
				{
					result = "";
				}
				return result;
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return "";
	}
	
	/**
	 * 
	 * 描述：从list 的头部删除元素，并返回删除元素
	 * 作者：刘宝
	 * 时间：2015-5-25 下午10:08:09
	 * @param key
	 */
	public byte[] lpop(byte[] key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).lpop(key);
				}
				else if (jedis instanceof ShardedJedis)
				{
					return ((ShardedJedis) jedis).lpop(key);
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).lpop(key);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：从list 的尾部删除元素，并返回删除元素
	 * 作者：刘宝
	 * 时间：2015-5-25 下午10:08:52
	 * @param key
	 * @return
	 */
	public String rpop(String key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				String result = jedis.rpop(key);
				if (ObjectUtil.isEmpty(result) || "nil".equalsIgnoreCase(result))
				{
					result = "";
				}
				return result;
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return "";
	}
	
	/**
	 * 
	 * 描述：从list 的尾部删除元素，并返回删除元素
	 * 作者：刘宝
	 * 时间：2015-5-25 下午10:08:52
	 * @param key
	 * @return
	 */
	public byte[] rpop(byte[] key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).rpop(key);
				}
				else if (jedis instanceof ShardedJedis)
				{
					return ((ShardedJedis) jedis).rpop(key);
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).rpop(key);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回名称为key 的list 中index 位置的元素
	 * 作者：刘宝
	 * 时间：2015-5-25 下午10:10:40
	 * @param key
	 * @param index
	 * @return
	 */
	public String lindex(String key, long index)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				String result = jedis.lindex(key, index);
				if (ObjectUtil.isEmpty(result) || "nil".equalsIgnoreCase(result))
				{
					result = "";
				}
				return result;
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return "";
	}
	
	/**
	 * 
	 * 描述：返回名称为key 的list 中index 位置的元素
	 * 作者：刘宝
	 * 时间：2015-5-25 下午10:10:40
	 * @param key
	 * @param index
	 * @return
	 */
	public byte[] lindex(byte[] key, long index)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).lindex(key,index);
				}
				else if (jedis instanceof ShardedJedis)
				{
					return ((ShardedJedis) jedis).lindex(key,index);
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).lindex(key,index);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回key 对应list 的长度
	 * 作者：刘宝
	 * 时间：2015-5-25 下午10:13:11
	 * @param key
	 * @return
	 */
	public Long llen(String key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.llen(key);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：从第一个list 的尾部移除元素并添加到第二个list 的头部,最后返回被移除的元素值，整个操作是原子的.如果第一个list 是空或者不存在返回nil
	 * 作者：刘宝
	 * 时间：2015-5-25 下午10:14:38
	 * @param key
	 * @param key1
	 * @return
	 */
	public String rpoplpush(String key, String key1)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				String result = "";
				if (jedis instanceof Jedis)
				{
					result = ((Jedis) jedis).rpoplpush(key, key1);
					if (ObjectUtil.isEmpty(result) || "nil".equalsIgnoreCase(result))
					{
						result = "";
					}
				}
				else if (jedis instanceof JedisCluster)
				{
					result = ((JedisCluster) jedis).rpoplpush(key, key1);
					if (ObjectUtil.isEmpty(result) || "nil".equalsIgnoreCase(result))
					{
						result = "";
					}
				}
				else
				{
					result = ((JedisCommands) jedis).rpop(key);
					if (ObjectUtil.isEmpty(result) || "nil".equalsIgnoreCase(result))
					{
						result = "";
					}
					((JedisCommands) jedis).lpush(key1, result);
				}
				return result;
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return "";
	}
	
	/**
	 * 
	 * 描述：插入数据
	 * 作者：刘宝
	 * 时间：2017-4-28 下午11:41:56
	 * @param key
	 * @param paramLIST_POSITION
	 * @param pivot
	 * @param value
	 * @return
	 */
	public Long linsert(String key, BinaryClient.LIST_POSITION paramLIST_POSITION, String pivot, String value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.linsert(key, paramLIST_POSITION, pivot, value);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：插入数据
	 * 作者：刘宝
	 * 时间：2017-4-28 下午11:41:56
	 * @param key
	 * @param paramLIST_POSITION
	 * @param pivot
	 * @param value
	 * @return
	 */
	public Long linsert(String key, BinaryClient.LIST_POSITION paramLIST_POSITION, byte[] pivot, byte[] value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).linsert(key.getBytes(), paramLIST_POSITION, pivot, value);
				}
				else if (jedis instanceof ShardedJedis)
				{
					return ((ShardedJedis) jedis).linsert(key.getBytes(), paramLIST_POSITION, pivot, value);
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).linsert(key.getBytes(), paramLIST_POSITION, pivot, value);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：插入存储在列表的头部的键值，仅当键已经存在，并持有(它是)列表。
	 * 作者：刘宝
	 * 时间：2017-4-28 下午11:45:07
	 * @param key
	 * @param value
	 * @return
	 */
	public Long lpushx(String key, String... value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.lpushx(key, value);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：插入存储在列表的头部的键值，仅当键已经存在，并持有(它是)列表。
	 * 作者：刘宝
	 * 时间：2017-4-28 下午11:45:07
	 * @param key
	 * @param value
	 * @return
	 */
	public Long lpushx(String key, byte[]... value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).lpushx(key.getBytes(),value);
				}
				else if (jedis instanceof ShardedJedis)
				{
					return ((ShardedJedis) jedis).lpushx(key.getBytes(),value);
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).lpushx(key.getBytes(),value);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：插入存储在列表的尾部的键值，仅当键已经存在，并持有(它是)列表。
	 * 作者：刘宝
	 * 时间：2017-4-28 下午11:45:17
	 * @param key
	 * @param value
	 * @return
	 */
	public Long rpushx(String key, String... value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.rpushx(key, value);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：插入存储在列表的尾部的键值，仅当键已经存在，并持有(它是)列表。
	 * 作者：刘宝
	 * 时间：2017-4-28 下午11:45:17
	 * @param key
	 * @param value
	 * @return
	 */
	public Long rpushx(String key, byte[]... value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).rpushx(key.getBytes(),value);
				}
				else if (jedis instanceof ShardedJedis)
				{
					return ((ShardedJedis) jedis).rpushx(key.getBytes(),value);
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).rpushx(key.getBytes(),value);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：它是 LPOP 命令的阻塞版本，当给定列表内没有任何元素可供弹出的时候，连接将被 BLPOP 命令阻塞，直到等待超时或发现可弹出元素为止。
	 * 作者：刘宝
	 * 时间：2017-4-28 下午11:50:22
	 * @param paramInt
	 * @param paramString
	 * @return
	 */
	public List<String> blpop(int paramInt, String paramString)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.blpop(paramInt, paramString);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	public List<String> brpop(int paramInt, String paramString)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.brpop(paramInt, paramString);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	public List<String> blpop(int timeout, String... keys)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).blpop(timeout, keys);
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).blpop(timeout, keys);
				}
				else
				{
					List<String> result = new ArrayList<String>();
					if (keys != null && keys.length > 0)
					{
						for (int i = 0; i < keys.length; i++)
						{
							List r = ((JedisCommands) jedis).blpop(timeout, keys[i]);
							if (r != null)
							{
								result.addAll(r);
							}
						}
					}
					return result;
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	public List<String> brpop(int timeout, String... keys)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).brpop(timeout, keys);
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).brpop(timeout, keys);
				}
				else
				{
					List<String> result = new ArrayList<String>();
					if (keys != null && keys.length > 0)
					{
						for (int i = 0; i < keys.length; i++)
						{
							List r = ((JedisCommands) jedis).brpop(timeout, keys[i]);
							if (r != null)
							{
								result.addAll(r);
							}
						}
					}
					return result;
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	public String brpoplpush(String paramString1, String paramString2, int paramInt)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				String result = "";
				if (jedis instanceof Jedis)
				{
					result = ((Jedis) jedis).brpoplpush(paramString1, paramString2, paramInt);
					if (ObjectUtil.isEmpty(result) || "nil".equalsIgnoreCase(result))
					{
						result = "";
					}
				}
				else if (jedis instanceof ShardedJedis)
				{
					log.error("当前API[brpoplpush]不支持ShardedJedis分片模式。");
				}
				else if (jedis instanceof JedisCluster)
				{
					result = ((JedisCluster) jedis).brpoplpush(paramString1, paramString2, paramInt);
					if (ObjectUtil.isEmpty(result) || "nil".equalsIgnoreCase(result))
					{
						result = "";
					}
				}
				return result;
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return "";
	}
	
	public Long publish(String paramString1, String paramString2)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).publish(paramString1, paramString2);
				}
				else if (jedis instanceof ShardedJedis)
				{
					Object[] shardJedis = ((ShardedJedis) jedis).getAllShards().toArray();
					if(shardJedis != null && shardJedis.length > 0)
					{
						return ((Jedis)shardJedis[0]).publish(paramString1, paramString2);
					}
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).publish(paramString1, paramString2);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	public void subscribe(JedisPubSub paramJedisPubSub, String... paramArrayOfString)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					((Jedis) jedis).subscribe(paramJedisPubSub, paramArrayOfString);
				}
				else if (jedis instanceof ShardedJedis)
				{
					Object[] shardJedis = ((ShardedJedis) jedis).getAllShards().toArray();
					if(shardJedis != null && shardJedis.length > 0)
					{
						((Jedis)shardJedis[0]).subscribe(paramJedisPubSub, paramArrayOfString);
					}
				}
				else if (jedis instanceof JedisCluster)
				{
					((JedisCluster) jedis).subscribe(paramJedisPubSub, paramArrayOfString);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
	}
	
	public void psubscribe(JedisPubSub paramJedisPubSub, String... paramArrayOfString)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					((Jedis) jedis).psubscribe(paramJedisPubSub, paramArrayOfString);
				}
				else if (jedis instanceof ShardedJedis)
				{
					Object[] shardJedis = ((ShardedJedis) jedis).getAllShards().toArray();
					if(shardJedis != null && shardJedis.length > 0)
					{
						((Jedis)shardJedis[0]).psubscribe(paramJedisPubSub, paramArrayOfString);
					}
				}
				else if (jedis instanceof JedisCluster)
				{
					((JedisCluster) jedis).psubscribe(paramJedisPubSub, paramArrayOfString);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
	}
	
	public String randomKey()
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof MultiKeyCommands)
				{
					return ((MultiKeyCommands) jedis).randomKey();
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return "";
	}
	
	/**
	 * 
	 * 描述：向名称为key 的set 中添加元素
	 * 作者：刘宝
	 * 时间：2015-5-25 下午10:21:19
	 * @param key
	 * @param value
	 * @return
	 */
	public Long sadd(String key, String... value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.sadd(key, value);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：删除名称为key 的set 中的元素member
	 * 作者：刘宝
	 * 时间：2015-5-25 下午10:22:29
	 * @param key
	 * @param value
	 * @return
	 */
	public Long srem(String key, String... value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.srem(key, value);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：随机返回并删除名称为key 的set 中一个元素
	 * 作者：刘宝
	 * 时间：2015-5-25 下午10:23:29
	 * @param key
	 * @return
	 */
	public String spop(String key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				String result = jedis.spop(key);
				if (ObjectUtil.isEmpty(result) || "nil".equalsIgnoreCase(result))
				{
					result = "";
				}
				return result;
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return "";
	}
	
	/**
	 * 
	 * 描述：随机返回并删除名称为key 的set 中num个元素
	 * 作者：刘宝
	 * 时间：2017-4-28 下午11:00:50
	 * @param key
	 * @param num
	 * @return
	 */
	public Set<String> spop(String key, long num)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.spop(key, num);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回所有给定key 与第一个key 的差集
	 * 作者：刘宝
	 * 时间：2015-5-25 下午10:26:12
	 * @param key
	 * @param key1
	 * @return
	 */
	public Set<String> sdiff(String key, String key1)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).sdiff(key, key1);
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).sdiff(key, key1);
				}
				else
				{
					Set<String> set1 = ((JedisCommands) jedis).zrange(key, 0, -1);
					Set<String> set2 = ((JedisCommands) jedis).zrange(key1, 0, -1);
					if (set1 != null && set2 != null)
					{
						set1.removeAll(set2);
					}
					return set1;
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回所有给定key 与第一个key 的差集
	 * 作者：刘宝
	 * 时间：2015-5-25 下午10:26:12
	 * @param key
	 * @param key1
	 * @return
	 */
	public Set<String> sdiff(String... key)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).sdiff(key);
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).sdiff(key);
				}
				else
				{
					Set<String> set = ((JedisCommands) jedis).zrange(key[0], 0, -1);
					if (set != null)
					{
						for (int index = 1; index < key.length; index++)
						{
							Set<String> temp = ((JedisCommands) jedis).zrange(key[index], 0, -1);
							if (temp != null)
							{
								set.removeAll(temp);
							}
						}
					}
					return set;
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回所有给定key 的交集
	 * 作者：刘宝
	 * 时间：2015-5-25 下午10:27:09
	 * @param key
	 * @param key1
	 * @return
	 */
	public Set<String> sinter(String key, String key1)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).sinter(key, key1);
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).sinter(key, key1);
				}
				else
				{
					Set<String> set1 = ((JedisCommands) jedis).zrange(key, 0, -1);
					Set<String> set2 = ((JedisCommands) jedis).zrange(key1, 0, -1);
					if (set1 != null && set2 != null)
					{
						set1.retainAll(set2);
					}
					return set1;
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回所有给定key 的交集
	 * 作者：刘宝
	 * 时间：2015-5-25 下午10:27:09
	 * @param key
	 * @param key1
	 * @return
	 */
	public Set<String> sinter(String... key)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).sinter(key);
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).sinter(key);
				}
				else
				{
					Set<String> set = ((JedisCommands) jedis).zrange(key[0], 0, -1);
					if (set != null)
					{
						for (int index = 1; index < key.length; index++)
						{
							Set<String> temp = ((JedisCommands) jedis).zrange(key[index], 0, -1);
							if (temp != null)
							{
								set.retainAll(temp);
							}
						}
					}
					return set;
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回所有给定key 的并集
	 * 作者：刘宝
	 * 时间：2015-5-25 下午10:28:06
	 * @param key
	 * @param key1
	 * @return
	 */
	public Set<String> sunion(String key, String key1)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).sunion(key, key1);
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).sunion(key, key1);
				}
				else
				{
					Set<String> set1 = ((JedisCommands) jedis).zrange(key, 0, -1);
					Set<String> set2 = ((JedisCommands) jedis).zrange(key1, 0, -1);
					if (set1 != null && set2 != null)
					{
						set1.addAll(set2);
					}
					return set1;
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回所有给定key 的并集
	 * 作者：刘宝
	 * 时间：2015-5-25 下午10:28:06
	 * @param key
	 * @param key1
	 * @return
	 */
	public Set<String> sunion(String... key)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).sunion(key);
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).sunion(key);
				}
				else
				{
					Set<String> set = new HashSet<String>();
					for (int index = 0; index < key.length; index++)
					{
						Set<String> temp = ((JedisCommands) jedis).zrange(key[index], 0, -1);
						if (temp != null)
						{
							set.addAll(temp);
						}
					}
					return set;
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回名称为key 的set 的元素个数
	 * 作者：刘宝
	 * 时间：2015-5-25 下午10:29:27
	 * @param key
	 * @param value
	 * @return
	 */
	public Long scard(String key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.scard(key);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：测试member 是否是名称为key 的set 的元素
	 * 作者：刘宝
	 * 时间：2015-5-25 下午10:32:10
	 * @param key
	 * @param value
	 * @return
	 */
	public boolean sismember(String key, String value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				Boolean result = jedis.sismember(key, value);
				if (result != null)
				{
					return result.booleanValue();
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return false;
	}
	
	/**
	 * 
	 * 描述：返回指定key的集合Set
	 * 作者：刘宝
	 * 时间：2017-4-27 下午09:29:49
	 * @param key
	 * @return
	 */
	public Set<String> smembers(String key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.smembers(key);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：随机获取一个集合的值
	 * 作者：刘宝
	 * 时间：2017-4-28 下午11:03:05
	 * @param key
	 * @return
	 */
	public String srandmember(String key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				String result = jedis.srandmember(key);
				if (ObjectUtil.isEmpty(result) || "nil".equalsIgnoreCase(result))
				{
					result = "";
				}
				return result;
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return "";
	}
	
	/**
	 * 
	 * 描述：随机获取一个集合的多个值
	 * 作者：刘宝
	 * 时间：2017-4-28 下午11:04:09
	 * @param key
	 * @param num
	 * @return
	 */
	public List<String> srandmember(String key, int num)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.srandmember(key, num);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	public Long sdiffstore(String paramString, String... paramArrayOfString)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).sdiffstore(paramString, paramArrayOfString);
				}
				else if (jedis instanceof ShardedJedis)
				{
					log.error("当前API[sdiffstore]不支持ShardedJedis分片模式。");
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).sdiffstore(paramString, paramArrayOfString);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	public Long sinterstore(String paramString, String... paramArrayOfString)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).sinterstore(paramString, paramArrayOfString);
				}
				else if (jedis instanceof ShardedJedis)
				{
					log.error("当前API[sinterstore]不支持ShardedJedis分片模式。");
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).sinterstore(paramString, paramArrayOfString);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	public Long smove(String paramString1, String paramString2, String paramString3)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).smove(paramString1, paramString2, paramString3);
				}
				else if (jedis instanceof ShardedJedis)
				{
					log.error("当前API[smove]不支持ShardedJedis分片模式。");
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).smove(paramString1, paramString2, paramString3);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	public Long sort(String paramString1, SortingParams paramSortingParams, String paramString2)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).sort(paramString1, paramSortingParams, paramString2);
				}
				else if (jedis instanceof ShardedJedis)
				{
					log.error("当前API[sort]不支持ShardedJedis分片模式。");
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).sort(paramString1, paramSortingParams, paramString2);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	public Long sort(String paramString1, String paramString2)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).sort(paramString1, paramString2);
				}
				else if (jedis instanceof ShardedJedis)
				{
					log.error("当前API[sort]不支持ShardedJedis分片模式。");
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).sort(paramString1, paramString2);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	public Long sunionstore(String paramString, String... paramArrayOfString)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).sunionstore(paramString, paramArrayOfString);
				}
				else if (jedis instanceof ShardedJedis)
				{
					log.error("当前API[sunionstore]不支持ShardedJedis分片模式。");
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).sunionstore(paramString, paramArrayOfString);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：向名称为key 的zset 中添加元素value，score 用于排序。如果该元素已经存在，则根据score 更新该元素的顺序
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:19:34
	 * @param key
	 * @param value
	 * @return
	 */
	public Long zadd(String key, String value, double score)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zadd(key, score, value);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：向名称为key 的zset 中添加元素value，score 用于排序。如果该元素已经存在，则根据score 更新该元素的顺序
	 * 作者：刘宝
	 * 时间：2017-4-28 下午11:18:09
	 * @param key
	 * @param value
	 * @param score
	 * @param params
	 * @return
	 */
	public Long zadd(String key, String value, double score, ZAddParams params)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zadd(key, score, value, params);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	public Long zadd(String key, Map<String, Double> paramMap)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zadd(key, paramMap);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	public Long zadd(String key, Map<String, Double> paramMap, ZAddParams paramZAddParams)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zadd(key, paramMap, paramZAddParams);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：删除名称为key 的zset 中的元素member,支持批量删除多个
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:23:11
	 * @param key
	 * @param value
	 * @return
	 */
	public Long zrem(String key, String... value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrem(key, value);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：返回名称为key 的zset 中value 元素的排名(按score 从小到大排序)即下标
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:27:23
	 * @param key
	 * @param value
	 * @return
	 */
	public Long zrank(String key, String value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrank(key, value);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：返回名称为key 的zset 中value 元素的排名(按score 从大到小排序)即下标
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:28:40
	 * @param key
	 * @param value
	 * @return
	 */
	public Long zrevrank(String key, String value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrevrank(key, value);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：返回名称为key 的zset（按score 从小到大排序）中的index 从start 到end 的所有元素
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:31:47
	 * @param key
	 * @return
	 */
	public Set<String> zrange(String key)
	{
		return this.zrange(key, 0, -1);
	}
	
	/**
	 * 
	 * 描述：返回名称为key 的zset（按score 从大到小排序）中的index 从start 到end 的所有元素
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:33:25
	 * @param key
	 * @return
	 */
	public Set<String> zrevrange(String key)
	{
		return this.zrevrange(key, 0, -1);
	}
	
	/**
	 * 
	 * 描述：返回名称为key 的zset（按score 从小到大排序）中的index 从start 到end 的所有元素
	 * 作者：刘宝
	 * 时间：2017-4-15 下午03:02:40
	 * @param key  
	 * @param start  开始
	 * @param end    结束
	 * @return
	 */
	public Set<String> zrange(String key, long start, long end)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrange(key, start, end);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回名称为key 的zset（按score 从大到小排序）中的index 从start 到end 的所有元素
	 * 作者：刘宝
	 * 时间：2017-4-15 下午03:05:05
	 * @param key
	 * @param start 开始
	 * @param end   结束
	 * @return
	 */
	public Set<String> zrevrange(String key, long start, long end)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrevrange(key, start, end);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回集合中score 在给定区间的元素（按score 从小到大排序）
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:35:19
	 * @param key
	 * @param min
	 * @param max
	 * @return
	 */
	public Set<String> zrangebyscore(String key, double min, double max)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrangeByScore(key, min, max);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回集合中score 在给定区间的元素（按score 从大到小排序）
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:35:19
	 * @param key
	 * @param min
	 * @param max
	 * @return
	 */
	public Set<String> zrevrangebyscore(String key, double min, double max)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrevrangeByScore(key, min, max);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回集合中在给定区间的元素（按score 从小到大排序）
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:35:19
	 * @param key
	 * @param arg1
	 * @param arg1
	 * @return
	 */
	public Set<String> zrangebyscore(String key, String arg1, String arg2)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrangeByScore(key, arg1, arg2);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回集合中在给定区间的元素（按score 从大到小排序）
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:35:19
	 * @param key
	 * @param arg1
	 * @param arg1
	 * @return
	 */
	public Set<String> zrevrangebyscore(String key, String arg1, String arg2)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrevrangeByScore(key, arg1, arg2);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回集合中在给定区间的元素，分数+索引（按score 从小到大排序）
	 * 作者：刘宝
	 * 时间：2017-4-24 下午01:38:23
	 * @param key
	 * @param min
	 * @param max
	 * @param start
	 * @param end
	 * @return
	 */
	public Set<String> zrangebyscore(String key, double min, double max, int start, int end)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrangeByScore(key, min, max, start, end);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回集合中在给定区间的元素，分数+索引（按score 从大到小排序）
	 * 作者：刘宝
	 * 时间：2017-4-24 下午01:38:23
	 * @param key
	 * @param min
	 * @param max
	 * @param start
	 * @param end
	 * @return
	 */
	public Set<String> zrevrangebyscore(String key, double min, double max, int start, int end)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrevrangeByScore(key, min, max, start, end);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回集合中在给定区间的元素,分数+索引（按score 从小到大排序)
	 * 作者：刘宝
	 * 时间：2017-4-24 下午01:38:23
	 * @param key
	 * @param min
	 * @param max
	 * @param start
	 * @param end
	 * @return
	 */
	public Set<String> zrangebyscore(String key, String min, String max, int start, int end)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrangeByScore(key, min, max, start, end);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回集合中在给定区间的元素,分数+索引（按score 从大到小排序)
	 * 作者：刘宝
	 * 时间：2017-4-24 下午01:38:23
	 * @param key
	 * @param min
	 * @param max
	 * @param start
	 * @param end
	 * @return
	 */
	public Set<String> zrevrangebyscore(String key, String min, String max, int start, int end)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrevrangeByScore(key, min, max, start, end);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回名称为key 的zset（按score 从小到大排序）中的index 从start 到end 的所有元素
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:35:19
	 * @param key
	 * @param arg1
	 * @param arg1
	 * @return
	 */
	public Set<Tuple> zrangewithscores(String key, long start, long end)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrangeWithScores(key, start, end);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回名称为key 的zset（按score 从大到小排序）中的index 从start 到end 的所有元素
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:35:19
	 * @param key
	 * @param arg1
	 * @param arg1
	 * @return
	 */
	public Set<Tuple> zrevrangewithscores(String key, long start, long end)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrevrangeWithScores(key, start, end);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回集合中在给定分数区间的元素（按score 从小到大排序）
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:35:19
	 * @param key
	 * @param arg1
	 * @param arg1
	 * @return
	 */
	public Set<Tuple> zrangebyscorewithscores(String key, double min, double max)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrangeByScoreWithScores(key, min, max);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回集合中在给定分数区间的元素（按score 从大到小排序）
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:35:19
	 * @param key
	 * @param arg1
	 * @param arg1
	 * @return
	 */
	public Set<Tuple> zrevrangebyscorewithscores(String key, double min, double max)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrevrangeByScoreWithScores(key, min, max);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回集合中在给定分数区间的元素（按score 从小到大排序）
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:35:19
	 * @param key
	 * @param arg1
	 * @param arg1
	 * @return
	 */
	public Set<Tuple> zrangebyscorewithscores(String key, String arg1, String arg2)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrangeByScoreWithScores(key, arg1, arg2);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回集合中在给定分数区间的元素（按score 从大到小排序）
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:35:19
	 * @param key
	 * @param arg1
	 * @param arg1
	 * @return
	 */
	public Set<Tuple> zrevrangebyscorewithscores(String key, String arg1, String arg2)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrevrangeByScoreWithScores(key, arg1, arg2);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回集合中在给定区间的元素,分数+索引（按score 从小到大排序）
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:35:19
	 * @param key
	 * @param arg1
	 * @param arg1
	 * @return
	 */
	public Set<Tuple> zrangebyscorewithscores(String key, double min, double max, int start, int end)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrangeByScoreWithScores(key, min, max, start, end);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回集合中在给定区间的元素,分数+索引（按score 从大到小排序）
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:35:19
	 * @param key
	 * @param arg1
	 * @param arg1
	 * @return
	 */
	public Set<Tuple> zrevrangebyscorewithscores(String key, double min, double max, int start, int end)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrevrangeByScoreWithScores(key, min, max, start, end);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回集合中在给定区间的元素,分数+索引（按score 从小到大排序）
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:35:19
	 * @param key
	 * @param arg1
	 * @param arg1
	 * @return
	 */
	public Set<Tuple> zrangebyscorewithscores(String key, String min, String max, int start, int end)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrangeByScoreWithScores(key, min, max, start, end);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回集合中在给定区间的元素,分数+索引（按score 从大到小排序）
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:35:19
	 * @param key
	 * @param arg1
	 * @param arg1
	 * @return
	 */
	public Set<Tuple> zrevrangebyscorewithscores(String key, String min, String max, int start, int end)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrevrangeByScoreWithScores(key, min, max, start, end);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回集合中score 在给定区间的数量
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:36:30
	 * @param key
	 * @param min
	 * @param max
	 * @return
	 */
	public Long zcount(String key, double min, double max)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zcount(key, min, max);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：返回集合中在给定区间的数量
	 * 作者：刘宝
	 * 时间：2017-4-17 下午01:15:58
	 * @param key
	 * @param arg1
	 * @param arg2
	 * @return
	 */
	public Long zcount(String key, String arg1, String arg2)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zcount(key, arg1, arg2);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：返回集合中元素个数
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:37:23
	 * @param key
	 * @return
	 */
	public Long zcard(String key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zcard(key);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：返回给定元素对应的score
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:38:16
	 * @param key
	 * @param value
	 * @return
	 */
	public Double zscore(String key, String value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zscore(key, value);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Double.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：删除集合中排名在给定区间的元素
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:40:55
	 * @param key
	 * @param start
	 * @param end
	 * @return
	 */
	public Long zremrangebyrank(String key, long start, long end)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zremrangeByRank(key, start, end);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：删除集合中score 在给定区间的元素
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:44:31
	 * @param key
	 * @param min
	 * @param max
	 * @return
	 */
	public Long zremrangebyscore(String key, double min, double max)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zremrangeByScore(key, min, max);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：删除集合中score 在给定区间的元素
	 * 作者：刘宝
	 * 时间：2015-5-26 上午12:44:31
	 * @param key
	 * @param arg1
	 * @param arg2
	 * @return
	 */
	public Long zremrangebyscore(String key, String arg1, String arg2)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zremrangeByScore(key, arg1, arg2);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	public Long zinterstore(String paramString, String... paramArrayOfString)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).zinterstore(paramString, paramArrayOfString);
				}
				else if (jedis instanceof ShardedJedis)
				{
					log.error("当前API[zinterstore]不支持ShardedJedis分片模式。");
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).zinterstore(paramString, paramArrayOfString);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	public Long zinterstore(String paramString, ZParams paramZParams, String... paramArrayOfString)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).zinterstore(paramString, paramZParams, paramArrayOfString);
				}
				else if (jedis instanceof ShardedJedis)
				{
					log.error("当前API[zinterstore]不支持ShardedJedis分片模式。");
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).zinterstore(paramString, paramZParams, paramArrayOfString);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	public Long zunionstore(String paramString, String... paramArrayOfString)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).zunionstore(paramString, paramArrayOfString);
				}
				else if (jedis instanceof ShardedJedis)
				{
					log.error("当前API[zunionstore]不支持ShardedJedis分片模式。");
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).zunionstore(paramString, paramArrayOfString);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	public Long zunionstore(String paramString, ZParams paramZParams, String... paramArrayOfString)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).zunionstore(paramString, paramZParams, paramArrayOfString);
				}
				else if (jedis instanceof ShardedJedis)
				{
					log.error("当前API[zunionstore]不支持ShardedJedis分片模式。");
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).zunionstore(paramString, paramZParams, paramArrayOfString);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：增长数据
	 * 作者：刘宝
	 * 时间：2017-4-28 下午11:22:29
	 * @param key
	 * @param value
	 * @param score
	 * @return
	 */
	public Double zincrby(String key, String value, double score)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zincrby(key, score, value);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Double.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：增长数据
	 * 作者：刘宝
	 * 时间：2017-4-28 下午11:24:15
	 * @param key
	 * @param value
	 * @param score
	 * @param paramZIncrByParams
	 * @return
	 */
	public Double zincrby(String key, String value, double score, ZIncrByParams paramZIncrByParams)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zincrby(key, score, value, paramZIncrByParams);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Double.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：排序
	 * 作者：刘宝
	 * 时间：2017-4-28 下午11:25:19
	 * @param paramString
	 * @return
	 */
	public List<String> sort(String paramString)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.sort(paramString);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：排序
	 * 作者：刘宝
	 * 时间：2017-4-28 下午11:26:02
	 * @param paramString
	 * @param paramSortingParams
	 * @return
	 */
	public List<String> sort(String paramString, SortingParams paramSortingParams)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.sort(paramString, paramSortingParams);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：计算有序集合中指定字典区间内成员数量。
	 * 作者：刘宝
	 * 时间：2017-4-28 下午11:29:46
	 * @param key
	 * @param min
	 * @param max
	 * @return
	 */
	public Long zlexcount(String key, String min, String max)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zlexcount(key, min, max);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：返回存储在键的排序集合在指定的范围元素,按照score升序
	 * 作者：刘宝
	 * 时间：2017-4-28 下午11:32:32
	 * @param key
	 * @param min
	 * @param max
	 * @return
	 */
	public Set<String> zrangeByLex(String key, String min, String max)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrangeByLex(key, min, max);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回存储在键的排序集合在指定的范围元素,按照score升序
	 * 作者：刘宝
	 * 时间：2017-4-28 下午11:38:07
	 * @param key
	 * @param min
	 * @param max
	 * @param start
	 * @param end
	 * @return
	 */
	public Set<String> zrangeByLex(String key, String min, String max, int start, int end)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrangeByLex(key, min, max, start, end);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回存储在键的排序集合在指定的范围元素,按照score降序
	 * 作者：刘宝
	 * 时间：2017-4-28 下午11:35:42
	 * @param key
	 * @param min
	 * @param max
	 * @return
	 */
	public Set<String> zrevrangeByLex(String key, String min, String max)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrevrangeByLex(key, min, max);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：返回存储在键的排序集合在指定的范围元素,按照score降序
	 * 作者：刘宝
	 * 时间：2017-4-28 下午11:37:52
	 * @param key
	 * @param min
	 * @param max
	 * @param start
	 * @param end
	 * @return
	 */
	public Set<String> zrevrangeByLex(String key, String min, String max, int start, int end)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zrevrangeByLex(key, min, max, start, end);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：删除存储在键的排序集合在指定的范围元素
	 * 作者：刘宝
	 * 时间：2017-4-28 下午11:38:51
	 * @param key
	 * @param min
	 * @param max
	 * @return
	 */
	public Long zremrangeByLex(String key, String min, String max)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zremrangeByLex(key, min, max);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	/**
	 * 
	 * 描述：设置数据
	 * 作者：刘宝
	 * 时间：2017-4-28 下午10:07:07
	 * @param arg0
	 * @param arg1
	 * @param arg2
	 * @return
	 */
	public boolean setbit(String arg0, long arg1, boolean arg2)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				Boolean result = jedis.setbit(arg0, arg1, arg2);
				if (result != null)
				{
					return result.booleanValue();
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return false;
	}
	
	/**
	 * 
	 * 描述：设置数据
	 * 作者：刘宝
	 * 时间：2017-4-28 下午10:08:17
	 * @param arg0
	 * @param arg1
	 * @param arg2
	 * @return
	 */
	public boolean setbit(String arg0, long arg1, String arg2)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				Boolean result = jedis.setbit(arg0, arg1, arg2);
				if (result != null)
				{
					return result.booleanValue();
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return false;
	}
	
	/**
	 * 
	 * 描述：获取数据
	 * 作者：刘宝
	 * 时间：2017-4-28 下午10:09:44
	 * @param arg0
	 * @param arg1
	 * @return
	 */
	public boolean getbit(String arg0, long arg1)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				Boolean result = jedis.getbit(arg0, arg1);
				if (result != null)
				{
					return result.booleanValue();
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return false;
	}
	
	public Long bitcount(String key)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.bitcount(key);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	public Long bitcount(String paramString, long paramLong1, long paramLong2)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.bitcount(paramString, paramLong1, paramLong2);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	public Long bitpos(String paramString, boolean paramBoolean)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.bitpos(paramString, paramBoolean);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	public Long bitpos(String paramString, boolean paramBoolean, BitPosParams paramBitPosParams)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.bitpos(paramString, paramBoolean, paramBitPosParams);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	public List<Long> bitfield(String key, String... value)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.bitfield(key, value);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	public Long bitop(BitOP paramBitOP, String paramString, String... paramArrayOfString)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).bitop(paramBitOP, paramString, paramArrayOfString);
				}
				else if (jedis instanceof ShardedJedis)
				{
					log.error("当前API[bitop]不支持ShardedJedis分片模式。");
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).bitop(paramBitOP, paramString, paramArrayOfString);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	public ScanResult<String> scan(String paramString)
	{
		Object jedis = null;
		ScanResult<String> result = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					result = ((Jedis) jedis).scan(paramString);
				}
				else if (jedis instanceof ShardedJedis)
				{
					log.error("当前API[scan]不支持ShardedJedis分片模式。");
				}
				else if (jedis instanceof JedisCluster)
				{
					result = ((JedisCluster) jedis).scan(paramString, null);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return result;
	}
	
	public ScanResult<String> scan(String paramString, ScanParams paramScanParams)
	{
		Object jedis = null;
		ScanResult<String> result = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					result = ((Jedis) jedis).scan(paramString, paramScanParams);
				}
				else if (jedis instanceof ShardedJedis)
				{
					log.error("当前API[scan]不支持ShardedJedis分片模式。");
				}
				else if (jedis instanceof JedisCluster)
				{
					result = ((JedisCluster) jedis).scan(paramString, paramScanParams);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return result;
	}
	
	public ScanResult<Map.Entry<String, String>> hscan(String paramString1, String paramString2)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.hscan(paramString1, paramString2);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	public ScanResult<Map.Entry<String, String>> hscan(String paramString1, String paramString2, ScanParams paramScanParams)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.hscan(paramString1, paramString2, paramScanParams);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	public ScanResult<String> sscan(String paramString1, String paramString2)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.sscan(paramString1, paramString2);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	public ScanResult<String> sscan(String paramString1, String paramString2, ScanParams paramScanParams)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.sscan(paramString1, paramString2, paramScanParams);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	public ScanResult<Tuple> zscan(String paramString1, String paramString2)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zscan(paramString1, paramString2);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	public ScanResult<Tuple> zscan(String paramString1, String paramString2, ScanParams paramScanParams)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.zscan(paramString1, paramString2, paramScanParams);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	public Long pfadd(String paramString, String... paramArrayOfString)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.pfadd(paramString, paramArrayOfString);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	public long pfcount(String paramString)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.pfcount(paramString);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	public Long geoadd(String paramString1, double paramDouble1, double paramDouble2, String paramString2)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.geoadd(paramString1, paramDouble1, paramDouble2, paramString2);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	public boolean pfmerge(String paramString, String... paramArrayOfString)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				String result = "";
				if (jedis instanceof Jedis)
				{
					result = ((Jedis) jedis).pfmerge(paramString, paramArrayOfString);
				}
				else if (jedis instanceof ShardedJedis)
				{
					log.error("当前API[pfmerge]不支持ShardedJedis分片模式。");
				}
				else if (jedis instanceof JedisCluster)
				{
					result = ((JedisCluster) jedis).pfmerge(paramString, paramArrayOfString);
				}
				return "OK".equalsIgnoreCase(result);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return false;
	}
	
	public long pfcount(String... paramArrayOfString)
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).pfcount(paramArrayOfString);
				}
				else if (jedis instanceof ShardedJedis)
				{
					log.error("当前API[pfcount]不支持ShardedJedis分片模式。");
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).pfcount(paramArrayOfString);
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return -1;
	}
	
	public Long geoadd(String paramString, Map<String, GeoCoordinate> paramMap)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.geoadd(paramString, paramMap);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Long.valueOf(-1);
	}
	
	public Double geodist(String paramString1, String paramString2, String paramString3)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.geodist(paramString1, paramString2, paramString3);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Double.valueOf(-1);
	}
	
	public Double geodist(String paramString1, String paramString2, String paramString3, GeoUnit paramGeoUnit)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.geodist(paramString1, paramString2, paramString3, paramGeoUnit);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return Double.valueOf(-1);
	}
	
	public List<String> geohash(String paramString, String... paramArrayOfString)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.geohash(paramString, paramArrayOfString);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	public List<GeoCoordinate> geopos(String paramString, String... paramArrayOfString)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.geopos(paramString, paramArrayOfString);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	public List<GeoRadiusResponse> georadius(String paramString, double paramDouble1, double paramDouble2, double paramDouble3, GeoUnit paramGeoUnit)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.georadius(paramString, paramDouble1, paramDouble2, paramDouble3, paramGeoUnit);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	public List<GeoRadiusResponse> georadius(String paramString, double paramDouble1, double paramDouble2, double paramDouble3, GeoUnit paramGeoUnit, GeoRadiusParam paramGeoRadiusParam)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.georadius(paramString, paramDouble1, paramDouble2, paramDouble3, paramGeoUnit, paramGeoRadiusParam);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	public List<GeoRadiusResponse> georadiusByMember(String paramString1, String paramString2, double paramDouble, GeoUnit paramGeoUnit)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.georadiusByMember(paramString1, paramString2, paramDouble, paramGeoUnit);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	public List<GeoRadiusResponse> georadiusByMember(String paramString1, String paramString2, double paramDouble, GeoUnit paramGeoUnit, GeoRadiusParam paramGeoRadiusParam)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				return jedis.georadiusByMember(paramString1, paramString2, paramDouble, paramGeoUnit, paramGeoRadiusParam);
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return null;
	}
	
	/**
	 * 
	 * 描述：redis的管道操作，批量执行模式
	 * 作者：刘宝
	 * 时间：2017-12-18 下午02:14:09
	 * @param jedisPipeline
	 * @return
	 */
	public List<Object> syncPipelineAndReturnAll(JedisPipeline jedisPipeline)
	{
		JedisCommands jedis = null;
		boolean success = true;
		List<Object> results = null;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				PipelineBase pipeline = null;
				if(jedis instanceof Jedis)
				{
					pipeline = ((Jedis)jedis).pipelined();
				}
				else if(jedis instanceof ShardedJedis)
				{
					pipeline = ((ShardedJedis)jedis).pipelined();
				}
				else if (jedis instanceof JedisCluster)
				{
					pipeline = new JedisClusterPipeline((JedisCluster)jedis);
				}
				if(pipeline != null)
				{
					jedisPipeline.syncExcute(pipeline);
					if(jedis instanceof Jedis)
					{
						results = ((Pipeline)pipeline).syncAndReturnAll();
					}
					else if(jedis instanceof ShardedJedis)
					{
						results = ((ShardedJedisPipeline)pipeline).syncAndReturnAll();
					}
					else if (jedis instanceof JedisCluster)
					{
						results = ((JedisClusterPipeline)pipeline).syncAndReturnAll();
					}
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return results;
	}
	
	/**
	 * 
	 * 描述：redis的管道操作，批量执行模式
	 * 作者：刘宝
	 * 时间：2017-12-18 下午02:14:09
	 * @param jedisPipeline
	 * @return
	 */
	public void syncPipeline(JedisPipeline jedisPipeline)
	{
		JedisCommands jedis = null;
		boolean success = true;
		try
		{
			jedis = (JedisCommands) this.getJedis();
			if (jedis != null)
			{
				PipelineBase pipeline = null;
				if(jedis instanceof Jedis)
				{
					pipeline = ((Jedis)jedis).pipelined();
				}
				else if(jedis instanceof ShardedJedis)
				{
					pipeline = ((ShardedJedis)jedis).pipelined();
				}
				else if (jedis instanceof JedisCluster)
				{
					pipeline = new JedisClusterPipeline((JedisCluster)jedis);
				}
				if(pipeline != null)
				{
					jedisPipeline.syncExcute(pipeline);
					if(jedis instanceof Jedis)
					{
						((Pipeline)pipeline).sync();
					}
					else if(jedis instanceof ShardedJedis)
					{
						((ShardedJedisPipeline)pipeline).sync();
					}
					else if (jedis instanceof JedisCluster)
					{
						((JedisClusterPipeline)pipeline).sync();
					}
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
	}
	
	/**
	 * 
	 * 描述：获取数据库的大小
	 * 作者：刘宝
	 * 时间：2017-12-18 下午02:14:09
	 * @return
	 */
	public long dbSize()
	{
		Object jedis = null;
		boolean success = true;
		try
		{
			jedis = this.getJedis();
			if (jedis != null)
			{
				if (jedis instanceof Jedis)
				{
					return ((Jedis) jedis).dbSize();
				}
				else if (jedis instanceof JedisCluster)
				{
					return ((JedisCluster) jedis).dbSize();
				}
				else if (jedis instanceof ShardedJedis)
				{
					long dbSzie = 0;
					Collection<Jedis> nodes = ((ShardedJedis) jedis).getAllShards();
					for (Iterator iterator = nodes.iterator(); iterator.hasNext();)
					{
						Jedis connection = (Jedis) iterator.next();
						try
						{
							dbSzie += connection.dbSize();
						}
						finally
						{
							connection.close();
						}
					}
					return dbSzie;
				}
				else
				{
					long dbSzie = 0;
					List<Jedis> jedisList = RedisConnManager.getSingleConns(this.id);
					if (jedisList != null && jedisList.size() > 0)
					{
						for (Iterator<Jedis> iterator = jedisList.iterator(); iterator.hasNext();)
						{
							Jedis jedis2 = (Jedis) iterator.next();
							try
							{
								dbSzie += jedis2.dbSize();
							}
							finally
							{
								jedis2.disconnect();
							}
						}
					}
					return dbSzie;
				}
			}
		}
		catch (JedisException e)
		{
			success = false;
			log.error("", e);
			throw e;
		}
		finally
		{
			if (jedis != null)
			{
				RedisConnManager.returnJedis(jedis, this.id, success);
			}
		}
		return -1;
	}
}
